
<?php
/*生成加密*/
function getHash($str,$salt='xaoam'){
		$arr['salt'] = $salt;
		$arr['passwd'] = openssl_encrypt($str, 'DES-ECB',$salt,0);
		return $arr['passwd'];
}
function getSalt(){
	       $seed = '';
	        for($i = 0; $i < 16; $i++) {
	            $seed .= chr(mt_rand(0, 255));
	        }
	        $salt = substr(strtr(base64_encode($seed), '+', '.'), 0, 10);
	        return $salt;
}
function reKb($mb){
	return $mb*1024*1024;
}
/*生成工具栏操作*/
function getTool($act,$control){
		$html = '';
		foreach($act as $key=>$row){
			switch($row)
			{
			case "re":
				$html .='<button type="button" class="layui-btn layui-btn-sm am_re"><i class="iconfont icon-shuaxin"></i></button>';
				break;
			case "del":
				$html .= '<button type="button" class="layui-btn layui-btn-sm am_dels" data-url="' . url($control .'/' .$row) . '"><i class="iconfont icon-delete"></i></button>';
				break;
			case "dels":
				$html .= '<button type="button" class="layui-btn layui-btn-sm am_dels" data-url="' . url($control .'/' .$row) . '"><i class="iconfont icon-delete"></i></button>';
				break;
			case "add":
				$html .= '<button type="button" class="layui-btn layui-btn-sm am_add" data-url="' . url($control .'/' .$row) . '"><i class="iconfont icon-add"></i></button>';
				break;
			}
		}
		return $html;
}
/*生成操作*/
function getTabOpt($act,$control,$id){
		$html = '';
		foreach($act as $key=>$row){
			switch($row)
			{
			case "deail":
				$html .='<a class="layui-btn layui-btn-xs" data-url="' . url("@index/article/index",["id"=>$id]) .'" lay-event="deail">查看</a>';
				break;
			case "del":
				$html .= '<a class="layui-btn layui-btn-xs" data-url="' . url($control .'/' .$row,['id'=>$id]) . '" lay-event="del">删除</a>';
				break;
			case "edit":
				$html .= '<a class="layui-btn layui-btn-xs" data-url="' . url($control .'/' .$row,['id'=>$id]) . '" lay-event="edit">编辑</a>';
				break;
			}
		}
		return $html;
}

